home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / fifth21 / ascii.fiv next >
Text File  |  1986-01-06  |  2KB  |  44 lines

  1. CREATE ASCII
  2. CREATE WHITE
  3. EDIT
  4. \ White tests if the character on the top of stack is a white space character,
  5. \   that is, a space, cr, tab, or line feed.
  6. : white
  7.   dup  32 =     \ Space.
  8.   over 13 = or  \ CR.
  9.   over  9 = or  \ Tab.
  10.   over 10 = or  \ Line feed.
  11. ;
  12. ~UP
  13. EDIT
  14. \ Takes the next character in the input stream and generates the its ASCII
  15. \    value.  If the compiler is on, the code to push this ASCII representation
  16. \    onto the stack is generated. A compile error occurs if ASCII is followed
  17. \    by more than one character.
  18.  
  19. : ASCII
  20.  begin                      \ Find the beginning of the next word.
  21.    >in @ c@@ white          \ Get the next character and test if white space.
  22.    1 >in +!                 \ Move text pointer to next character.
  23.    while                    \ Loop while white space.
  24.    drop                     \ Drop character if it is white space.
  25.  repeat
  26.  dup if else                \ Test for end of text. (This is marked by 0)
  27.    cls                      \ Error if at end of text.
  28.   ." EOT error on ASCII routine"
  29.   abort
  30.  endif
  31.  >in @ c@@ white over 0= or \ Test that only one character follows.
  32.  if
  33.    drop                     \ Drop the white space character.
  34.  else
  35.    drop cls                 \ More than one character follows.
  36.    ." Illegal ASCII character"
  37.    abort
  38.  endif
  39.  state c@ if                \ If the compiler is on,
  40.    ['] literal execute      \   compile a push of the ASCII value to the stack.
  41.  endif
  42. ; immediate
  43. ~UP
  44. ABORT